<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>智能订餐</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/style.css">
    <link rel="stylesheet" href="/assets/base/Inforschool/css/layer.css">
</head>
<body>
<div class="wraper bg_white">
    <div class="headimg">
        <img src="/assets/base/Inforschool/images/head.jpg" alt="">
    </div>
    <div class="main">
        <div class="box flex padding-t0">
            <div class="iconfont icon-xingming font-gray2"></div>
            <input type="text" class="input font-gray" placeholder="请输入姓名" name="username" id="username">
        </div>
        <div class="box flex_between padding-2">
            <div class="iconfont icon-iPhone font-gray2"></div>
            <input type="text" class="input flex_1 font-gray" placeholder="请输入手机号码" name="tel" id="tel2">
            <a href="#" class="send font-12 text-center" id="post">发送验证码</a>
        </div>
        <div class="box flex">
            <div class="iconfont icon-mima font-gray2"></div>
            <input type="text" class="input font-gray" placeholder="请输入验证码" name="token" id="token">
        </div>
    </div>
    <a href="#" class="btn text-center font-16" id="reg">登录</a>
</div>
</body>
<script src="/assets/base/Inforschool/js/jquery-2.1.0.min.js"></script>
<script src="/assets/base/Inforschool/js/layer.js"></script>
<script src="/assets/base/Inforschool/js/public.js"></script>
<script>

//发送短信请求
    $('#post').click(function(){
        var tel = $('#tel2').val();
        if(tel==''|| tel==null){
            fm.alert('请输入手机号');
            return false;
        }
            var myreg = /^1[34578]\d{9}$/;
            if(!myreg.test(tel))
            {
                fm.alert('请输入有效的手机号码！');
                return false;
            }else{
            $.ajax({
                url:"/base/Inforschool/sendText",
                type:"get",
                data:{tel:tel},
                dataType:"json",
                success: function(msg){
                    console.log(msg);

                }
            });
        }

    });
//点击提交
    $('#reg').click(function(){
        var username =$('#username').val();
        var tel      =$('#tel2').val();
        var token    =$('#token').val();
        if(username==''|| username==null){
            fm.alert('请输入用户');
            return false;
        }
        if(tel==''|| tel==null){
            fm.alert('请输入手机号');
            return false;
        }
        var myreg = /^1[34578]\d{9}$/;
        if(!myreg.test(tel))
        {
            fm.alert('请输入有效的手机号码！');
            return false;
        }
        if(token==''|| token==null){
            fm.alert('请输入验证码');
            return false;
        }
        if (isNaN(token)){
            fm.alert('验证码只能输入数字');
            return false;
        }
            var info = {};
            info.username = username;
            info.tel = tel;
            info.token = token;
            $.ajax({
                'url': "/base/Inforschool/index",
                'data': info,
                'dataType':'json',
                'type': 'POST',
                success: function(data) {
                    if (data.status == 'S'){
                        setTimeout("reload('"+data.url+"')", 2000);
                        fm.alert(data.message);

                    }else{
                        fm.alert(data.message);
                        return false;
                    }
                }
            })
    });
    function reload(url) {
        window.location.href = url;
    }

    var height = $(window).height();
    $('.wraper').css('minHeight', height);

    var verifyTag = true;
    $('.box').on('click', '.send', function (e) {
        e.preventDefault();
        if (verifyTag) timeCountDown(this);
        else return;
    });
    // 验证倒计时
    function timeCountDown(elem, seconds) {
        verifyTag = false;
        if (typeof seconds == undefined || seconds == null) seconds = 60;
        setTimeout(function () {
            if (seconds > 0) {
                seconds--;
                $(elem).text('已发送 ' + seconds + 's').addClass('time');
                timeCountDown(elem, seconds);
            } else {
                $(elem).removeClass('time').text('获取验证码');
                verifyTag = true;
            }
        }, 1000);
    }

    // $('.btn').click(function () {
    //    fm.alert('验证码错误');
    // })
</script>
</html>